//
//  HLLiveMoreView.m
//  YueYue
//
//  Created by hulu001 on 2024/3/14.
//

#import "HLLiveMoreView.h"

@interface HLLiveMoreView ()

@property (nonatomic, strong) UIStackView *contentView;

@property (nonatomic, strong) UIView *bottomView;

@end

@implementation HLLiveMoreView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = [UIColor qmui_colorWithHexString:@"#FF161825"];

    self.contentView = [[UIStackView alloc] init];
    _contentView.axis = UILayoutConstraintAxisHorizontal;
    _contentView.distribution = UIStackViewDistributionEqualSpacing;
    _contentView.alignment = UIStackViewAlignmentCenter;
    [self addSubview:_contentView];
    [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(86);
        make.right.mas_equalTo(-86);
        make.top.mas_equalTo(30);
        make.bottom.mas_equalTo(-(SafeAreaInsetsConstantForDeviceWithNotch.bottom + 30));
    }];
    
    self.reportButton = [[QMUIButton alloc] init];
    [_reportButton setTitle:@"举报" forState:UIControlStateNormal];
    [_reportButton setTitleColor:HLTextColor3 forState:UIControlStateNormal];
    [_reportButton setImage:UIImageMake(@"live_in_report") forState:UIControlStateNormal];
    [_reportButton.titleLabel setFont:UIFontMake(13)];
    [_reportButton setImagePosition:QMUIButtonImagePositionTop];
    [_reportButton setSpacingBetweenImageAndTitle:8];
    [_contentView addArrangedSubview:_reportButton];
    
    self.chongButton = [[QMUIButton alloc] init];
    [_chongButton setTitle:@"充值" forState:UIControlStateNormal];
    [_chongButton setTitleColor:HLTextColor3 forState:UIControlStateNormal];
    [_chongButton setImage:UIImageMake(@"live_in_chong") forState:UIControlStateNormal];
    [_chongButton.titleLabel setFont:UIFontMake(13)];
    [_chongButton setImagePosition:QMUIButtonImagePositionTop];
    [_chongButton setSpacingBetweenImageAndTitle:8];
    [_contentView addArrangedSubview:_chongButton];
}

+ (void)showWitContentView:(HLLiveMoreView *)contentView
                    report:(HLCommonCallback)reportCallback
                     chong:(HLCommonCallback)chongCallback
{
    CGFloat height = 210;

    QMUIModalPresentationViewController *modalViewController = [[QMUIModalPresentationViewController alloc] init];
    modalViewController.contentViewMargins = UIEdgeInsetsMake(SCREEN_HEIGHT-height, 0, 0, 0);
    modalViewController.contentView = contentView;
    modalViewController.dimmingView.backgroundColor = UIColorClear;
    [modalViewController showWithAnimated:YES completion:nil];
    contentView.reportButton.qmui_tapBlock = ^(__kindof UIControl *sender) {
        [modalViewController hideWithAnimated:YES completion:nil];
        if (reportCallback) {
            reportCallback(@"1");
        }
    };
    contentView.chongButton.qmui_tapBlock = ^(__kindof UIControl *sender) {
        [modalViewController hideWithAnimated:YES completion:nil];
        if (chongCallback) {
            chongCallback(@"1");
        }
    };
    
}

@end
